#include <stdio.h>
// 计算 switch实现
int add(int x, int y)
{
    return x + y;
}
int sub(int x, int y)
{
    return x - y;
}
int mul(int x, int y)
{
    return x * y;
}
int div(int x, int y)
{
    return x / y;
}
void menu(){
    printf("******************\n");
    printf("**1.add    2.sub**\n");
    printf("**3.mul    4.div**\n");
    printf("**     0.exit   **\n");
    printf("******************\n");
}
int main()
{
    
    int num, x, y = 0;
    do{
        menu();
        printf("please input num \n");
        scanf("%d", &num);
        if(num == 0){
            return 0;
        }
        printf("please input two numbers \n");
        scanf("%d %d", &x, &y);
        switch (num)
        {
        case 1:
            printf("thr result is %d \n", add(x, y));
            break;
        case 2:
            printf("thr result is %d \n", sub(x, y));
            break;
        case 3:
            printf("thr result is %d \n", mul(x, y));
            break;
        case 4:
            printf("thr result is %d \n", div(x, y));
            break;
        default:
            break;
        }
    }while(num);

    return 0;
}
